Error Object

                   

An Error object contains details about data access errors, each of which pertains to a single operation involving DAO.



Remarks

Any operation involving DAO can generate one or more errors. For example, a call to an ODBC server might result in an error from the database server, an error from ODBC, and a DAO error. As each such error occurs, an Error object is placed in the Errors collection of the DBEngine object. A single event can therefore result in several Error objects appearing in the Errors collection.

When a subsequent DAO operation generates an error, the Errors collection is cleared, and one or more new Error objects are placed in the Errors collection. DAO operations that don't generate an error have no effect on the Errors collection.

The set of Error objects in the Errors collection describes one error. The first Error object is the lowest level error (the originating error), the second the next higher level error, and so forth. For example, if an ODBC error occurs while trying to open a Recordset object, the first Error object ù Errors(0) ù contains the lowest level ODBC error; subsequent errors contain the ODBC errors returned by the various layers of ODBC. In this case, the ODBC driver manager, and possibly the driver itself, return separate Error objects. The last Error object ù Errors.Count-1 ù contains the DAO error indicating that the object couldn't be opened.

Enumerating the specific errors in the Errors collection enables your error-handling routines to more precisely determine the cause and origin of an error, and take appropriate steps to recover. On both Microsoft Jet and ODBCDirect workspaces, you can read the Error objectÆs properties to obtain specific details about each error, including: